
package kaizone.haining.chaobohui.json;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONObject;

public class FirstReadDO extends JSONResponse {

    public static final String CULTURELIST = "cultureList";
    
    private Data data;

    public Data getData() {
        return data;
    }

    public void setData(Data data) {
        this.data = data;
    }
    
    public static FirstReadDO parseJson(String str) {
        FirstReadDO firstReadDO = new FirstReadDO();
        try {
            JSONObject jsonObject = new JSONObject(str);
            JSONResponse response = JSONResponse.parse(jsonObject);
            firstReadDO.setJSONResponse(response);
            
            JSONObject jsondata = jsonObject.optJSONObject(Data.DATA);
            if(jsondata != null){
                Data data = new Data();
                JSONArray jsonCultureArray = jsondata.optJSONArray(CULTURELIST);
                if(jsonCultureArray != null){
                    ArrayList<Item> cultureList = new ArrayList<Item>();
                    int len = jsonCultureArray.length();
                    for(int i=0; i<len; i++){
                        JSONObject jsonItem = jsonCultureArray.getJSONObject(i);
                        Item item = Item.parse(jsonItem);
                        cultureList.add(item);
                    }
                    data.setCultureList(cultureList);
                }
                
                JSONObject jsonIntro = jsondata.optJSONObject(Intro.INTRO);
                if(jsonIntro !=null ){
                    Intro intro = Intro.parse(jsonIntro);
                    data.setIntro(intro);
                }
                firstReadDO.setData(data);
            }
            return firstReadDO;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return firstReadDO;
    }

    public static Data parseData(JSONObject jsonObject) {
        Data data = new Data();

        return data;
    }
    
    public static class Data {
        
        public static final String DATA = "data";
        
        private Intro intro;

        private List<Item> cultureList;

        public Intro getIntro() {
            return intro;
        }

        public void setIntro(Intro intro) {
            this.intro = intro;
        }

        public List<Item> getCultureList() {
            return cultureList;
        }

        public void setCultureList(List<Item> cultureList) {
            this.cultureList = cultureList;
        }

    }

}
